package com.iisigroup.adrclient.common;

public class StringUtils {
	public static String removeSpace(String str) {
		if (str != null) {
			str = str.replaceAll("[\\s　]", "");
			if (str.length() == 0) {
				str = null;
			}
		}
		return str;
	}
	
	public static String trim(String str) {
		if (str != null) {
			str = str.replaceAll("^[\\s　]+", "").replaceAll("[\\s　]+$", "");
			if (str.length() == 0) {
				str = null;
			}
		}
		return str;
	}
	
	public static Integer parseFullCharNumbers(String str) {
		String regex = "[^\\d.]";
		if (str != null && str.length() > 0) {
			StringBuilder sb = new StringBuilder();
			for (char ch : str.toCharArray()) {
				int code = ch;
				code -= 65248;
				sb.append((char) code);
			}
			return Integer.parseInt(sb.toString().replaceAll(regex, ""));
		} else {
			return 0;
		}
	}
	
	public static boolean fullCharNumbersOnly(String str) {
		String regex = "\\d+";
		StringBuilder sb = new StringBuilder();
		if (str != null) {
			for (char ch : str.toCharArray()) {
				int code = ch;
				code -= 65248;
				sb.append((char) code);
			}
		}
		return sb.toString().matches(regex);
	}
}
